/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.gra.web;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.druid.support.json.JSONUtils;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.gra.service.BookService;
import com.thinkgem.jeesite.modules.gra.service.ScoreService;

/**
 * 书单管理Controller
 * @author wuzengli
 * @version 2017-05-03
 */
@Controller
@RequestMapping(value = "${adminPath}/gra/statistic")
public class StatisticController extends BaseController {
	
	@Autowired
	private BookService bookService;
	
	@Autowired
	private ScoreService scoreService;
	
	@RequestMapping(value = {"plan"})
	public String plan(HttpServletRequest request, HttpServletResponse response, Model model) {
		List<Map<String,Object>> bookStatistic = bookService.bookStatistic(); 
		model.addAttribute("bookStatistic", JSONUtils.toJSONString(bookStatistic));
		return "modules/gra/planStatistic";
	}

	@RequestMapping(value = {"check"})
	public String check( HttpServletRequest request, HttpServletResponse response, Model model) {
		List<Map<String,Object>> scoreStatistic = scoreService.scoreStatistic(); 
		model.addAttribute("scoreStatistic", JSONUtils.toJSONString(scoreStatistic));
		return "modules/gra/checkStatistic";
	}
}